<template>
  <view>
    <view class="w100 pt-20 pl-24 pr-24">
      <view class="w100 p-all-30 bgff br-20 mb-20" v-for="(item,index) in list" :key="index"  @click="toPage(item)">
        <view class="fs-30 fw-b col000 mb-30">{{item.name}}</view>
         <view class="w100 rows rowsm" style="flex-direction: row-reverse;">
        <view class="fs-24 col888">{{item.createTime}}</view>
        </view>
      </view>
      
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        list:[],
        total:0,
        limit: {
          pageNum: 1,
          pageSize: 10
        },
      };
    },
    onLoad(e) {
      this.getList()
      if(e.index == 2){
        uni.setNavigationBarTitle({
          title:'系统消息'
        })
      }
    },
    onReachBottom() {
      if (this.list.length < this.total) {
        this.limit.pageNum++;
        this.getList()
      }
    },
    onPullDownRefresh() {
      this.limit.pageNum = 1
      this.getList()
    },
    methods:{
      toPage(item){
        console.log(item)
        uni.setStorageSync('noticeDetail',item)
        uni.navigateTo({
          url:'/pages/msg/noticeDetail'
        })
      
      },
      getList(){
        this.$tools.axiosFromToken('POST',`pronotice/list?pageNum=${this.limit.pageNum}&pageSize=${this.limit.pageSize}`,{},'加载中').then(res => {
          if(res.code != 200) return this.$tools.showtt(res.msg)
            this.total = res.total
            if (this.limit.pageNum == 1) {
              this.list = res.rows;
            } else {
              this.list = [...this.list, ...res.rows];
            }
          this.list.forEach(item => {
            item.content = item.content.replace(/<img/gi,'<img style="max-width:100%"')
          })
        })
      }
    }
  }
</script>

<style lang="scss">

</style>
